package com.example.light.web.personal.service.impl;

import com.example.light.web.personal.dao.MessageMapper;
import com.example.light.web.personal.dao.SchedualMapper;
import com.example.light.web.personal.entity.Message;
import com.example.light.web.personal.entity.Schedual;
import com.example.light.web.personal.service.ThingService;
import com.example.light.web.personal.vo.ScheduleVO;
import com.example.light.web.system.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.ui.Model;

import java.util.List;

@Service
public class ThingServiceImpl implements ThingService {

    @Autowired
    private MessageMapper messageMapper;
    @Autowired
    private SchedualMapper schedualMapper;

    /**
     * 查询截至明天的未查留言清单
     * @param model
     * @param user
     */
    @Override
    public void showMsgList(Model model, User user) {
        List<Message> messages = messageMapper.showMessages(user.getUserEmail());
        messages.forEach(message -> {
            message.setMsgContent(message.getMsgContent().substring(0,100));
        });
        model.addAttribute("messages", messages);
    }

    @Override
    public void showPlan(Model model, User user) {
        List<Schedual> schedules = schedualMapper.showSchedules(user.getUserId());
        model.addAttribute("schedules",schedules);
    }
}
